//
//  LVHomeViewCell.swift
//  PhotoBrowser
//
//  Created by 刘伟 on 16/4/27.
//  Copyright © 2016年 刘伟. All rights reserved.
//

import UIKit
import SDWebImage

class LVHomeViewCell: UICollectionViewCell {
    
    
    lazy var testImageV : UIImageView = {
    
        let imageV = UIImageView()
        imageV.contentMode = .ScaleAspectFill
        imageV.clipsToBounds = true
        return imageV
    
    }()
    
    
    override func awakeFromNib() {
//        这个方法不会来????????
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        testImageV.frame = contentView.bounds
    }
    
//    定义模型属性
    var shop : LVShop?{
//        监听shop的改变
        didSet{
            
//            1.空值校验
            guard let urlString = shop?.q_pic_url else {
            return
            }
            
//            2.创建url
            guard let url = NSURL(string: urlString) else{
            return
            }
            
            contentView.addSubview(testImageV)
            
//            3.设置图片
            testImageV.sd_setImageWithURL(url, placeholderImage: UIImage(named: "empty_picture"))
        
        }
    }
}







